package com.epam.task.string.BookParts;

import java.text.BreakIterator;
import java.util.Locale;

/**
 * Created with IntelliJ IDEA.
 * User: zhunusbekova.arailym
 * Date: 22.08.13
 * Time: 13:41
 * To change this template use File | Settings | File Templates.
 */
public class Sentence extends TextPart<SentencePart>{
    private static final long serialVersionUID = 1L;

    public Sentence(String sentence) {
        BreakIterator iterator = BreakIterator.getWordInstance(new Locale("ru",
                "Ru"));
        iterator.setText(sentence);
        int start = iterator.first();
        for (int end = iterator.next(); end != BreakIterator.DONE; start = end, end = iterator
                .next()) {
            String sentencePart = sentence.substring(start, end);
            this.add(new Word(sentencePart));
        }
    }


}
